package com.zhcd.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zhcd.sys.pojo.Patient;
import com.zhcd.sys.mapper.PatientMapper;
import com.zhcd.sys.service.PatientService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author feifei
 * @since 2021-11-29
 */
@Service
public class PatientServiceImpl extends ServiceImpl<PatientMapper, Patient> implements PatientService {
    @Autowired
    private PatientMapper patientMapper;

    //查询全部患者
    @Override
    public List<Patient> getAll_Patient() {
        return patientMapper.selectList(null);
    }

    //按照条件(患者姓名、医院名称、科室名称、医生名称)查询患者
    @Override
    public List<Patient> getList_Patient(String patientname, String hospitalname, String departmentname, String doctorname) {
        QueryWrapper<Patient> objectQueryWrapper = new QueryWrapper<>();
        objectQueryWrapper.eq("PatientName",patientname)
                .eq("HospitalName",hospitalname)
                .eq("DepartmentName",departmentname)
                .eq("DoctorName",doctorname);
        return patientMapper.selectList(objectQueryWrapper);
    }

    //添加患者
    @Override
    public int ins_Patient(Patient patient) {
        return patientMapper.insert(patient);
    }

    //删除患者信息
    @Override
    public int del_Patient(int id) {
        return patientMapper.deleteById(id);
    }

    //修改患者信息
    @Override
    public int upd_Patinet(Patient patient) {
        return patientMapper.updateById(patient);
    }
}
